#include "GLFramebuffer.h"

GLFramebuffer::GLFramebuffer()
{
	glGenFramebuffers(1, &name);
	glBindFramebuffer(GL_FRAMEBUFFER, name);
}

GLFramebuffer::~GLFramebuffer()
{
	glDeleteFramebuffers(1, &name);
}

void GLFramebuffer::attach(GLTexture* texture, GLenum attachment)
{
	glBindFramebuffer(GL_FRAMEBUFFER, name);
	glFramebufferTexture(GL_FRAMEBUFFER, attachment, texture->name, 0);
}

void GLFramebuffer::setDrawBuffer(GLenum buf)
{
	GLenum bufs[1] = {buf};
	glBindFramebuffer(GL_FRAMEBUFFER, name);
	glDrawBuffers(1, bufs);
}

void GLFramebuffer::setDrawBuffers(GLsizei n, const GLenum* bufs)
{
	glBindFramebuffer(GL_FRAMEBUFFER, name);
	glDrawBuffers(n, bufs);
}